<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="model.*"%>
<%
	EmployeeModel obj;
	Object temp = request.getAttribute("document");
	if (temp != null) {
		try {
			obj = (EmployeeModel) temp;
		} catch (Exception ex) {
			obj = new EmployeeModel();
		}
	} else {
		obj = new EmployeeModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Employee </title>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/common.css" />
<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery-1.6.1.min.js"></script>

<script language="javascript" type="text/javascript">
	var requiredInputs = [['code','code_required'],['note','note_required'],['user_name','user_name_required'],['id_person','id_person_required'],['status','status_required'],['notification','notification_required']];
	var intInputs = [['id_person','id_person_invalid'],['status','status_invalid'],['notification','notification_invalid']];
	var doubleInputs = [];
	var dateInputs = [];
	var timeInputs = [];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
	<form action="employeeServlet?mode=insert" method="post"
        onSubmit="return checkInputs()"
        onreset="return confirm('Do you really want to reset the form?')">
		<table class="tblInput" border="1">
			<tr class="inputHeader">
				<td colspan="3" class="inputHeader">Create New Employee </td>
			</tr>
			<tr class="trField">
				<td class="tdFieldName">Code </td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="code" name="code" maxlength="20" value="<%=obj.getCode()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="code_required" class="errMsg" style="display: none;">Code  is required</span>
					<span id="code_invalid" class="errMsg" style="display: none;">Code  is invalid</span>
                    <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Note </td>				    <td class="tdFieldInput">
					<textarea id="note" name="note" rows="5" class="inputTextarea"><%=obj.getNote()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="note_required" class="errMsg" style="display: none;">Note  is required</span>
					<span id="note_invalid" class="errMsg" style="display: none;">Note  is invalid</span>
                    <span id="note_error" class="errMsg"><%=obj.errMsgs.Note%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">User Name </td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="user_name" name="user_name" maxlength="255" value="<%=obj.getUserName()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="user_name_required" class="errMsg" style="display: none;">User Name  is required</span>
					<span id="user_name_invalid" class="errMsg" style="display: none;">User Name  is invalid</span>
                    <span id="user_name_error" class="errMsg"><%=obj.errMsgs.UserName%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Person </td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_person" name="id_person" maxlength="10" value="<%=obj.getIdPerson()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_person_required" class="errMsg" style="display: none;">Id Person  is required</span> 
					<span id="id_person_invalid" class="errMsg" style="display: none;">Id Person  is invalid</span>
                    <span id="id_person_error" class="errMsg"><%=obj.errMsgs.IdPerson%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Status </td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="status" name="status" maxlength="10" value="<%=obj.getStatus()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="status_required" class="errMsg" style="display: none;">Status  is required</span> 
					<span id="status_invalid" class="errMsg" style="display: none;">Status  is invalid</span>
                    <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Is Draft </td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_is_draft" name="ckb_is_draft"
								onchange="toggleControls(['is_draft_true', 'is_draft_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="is_draft_true" name="is_draft" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="is_draft_false" name="is_draft" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Notification </td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="notification" name="notification" maxlength="10" value="<%=obj.getNotification()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="notification_required" class="errMsg" style="display: none;">Notification  is required</span> 
					<span id="notification_invalid" class="errMsg" style="display: none;">Notification  is invalid</span>
                    <span id="notification_error" class="errMsg"><%=obj.errMsgs.Notification%></span>
                </td></tr>
			
			<tr class="trInputBottom">
				<td class="trInputBottom" colspan="3">
					<table class="tblSubmit" align="center">
						<tr class="trSubmit">
							<td class="tdSubmit"><input type="submit" value="Submit" />
							</td>
							<td class="tdReset"><input type="reset" value="Reset" /></td>
						</tr>
					</table></td>
			</tr>
		</table>
	</form>
</body>
</html>